<template>
    <el-card shadow="never" class="aui-card--fill">
    <el-row :gutter="15" type="flex">
      <el-card style="width: 49%;margin-top: 0px;">
        <el-form
          ref="elFormCheck"
          :model="formCheck"
          size="mini"
          label-width="150px"
          label-position="left"
        >
          <el-form-item label="空箱入库登记:" style="font-size: 16px;font-weight: 700;"> </el-form-item>
          <el-form-item prop="contNo" label="箱号">
            <el-input v-model="formEmptyRegister.contNo" :style="{ width: '100%' }" 
            >
            </el-input>
          </el-form-item>
          <el-form-item prop="countType" label="箱类型">
            <el-select v-model="formEmptyRegister.countType" :style="{ width: '100%' }">
              <el-option
                v-for="item in optionsContType"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="contVolume " label="箱體積">
            <el-select v-model="formEmptyRegister.contVolume" :style="{ width: '100%' }">
              <el-option
                v-for="item in optionsContVolume"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item >
            <el-button
              icon="el-icon-folder-checked"
              size="mini"
              style="width: 40%"
              type="warning"
              @click="contBack"
            >
              料箱放行
            </el-button>
            <el-button
              type="primary"
              icon="el-icon-folder-checked"
              size="mini"
              style="float:right;width: 40%"
              @click="emptyContRegister"
            >
              空箱入库登记
            </el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-row>
    </el-card>
  </template>


<script>

export default {
  name: "Indtfm",
  components: {},
  props: [],
  data() {
    return {
      //空箱登记入库
      optionsContType: [ // 下拉框的选项数据
        {value: '1', label: '其他'},
        { value: '2', label: '10格' },
        { value: '3', label: '16格' }
      ],
      optionsContVolume: [
        {value: '62.3*43*24.3', label: '62.3cm*43cm*24.3cm'},
        { value: '62.3*43.5*31.5', label: '62.3cm*43.5cm*31.5cm' },
        { value: '61.5*42.5*38', label: '61.5cm*42.5cm*38cm'}

      ],
      formEmptyRegister:{
        contNo:'',
        countType:'',
        contVolume:'',
        requestType:'0',
        stn:''
      },
      //空箱登记入库 END

      formInve: {
        billInDtNo: null,
        itemId: "",
        itemName: "",
        planInQnty: null,
        actlInQnty: null,
        disPre: true,
        disNext: true,
        showTotal: "0/0",
      },
      formCheck: {
        billInDtNo: null,
        itemId: "",
        itemName: "",
        planInQnty: null,
        locateNo: null,
        isOrder: 1,
      },
      formInveList: [],
      formQuery: {
        contNo: "",
        pageNum: 1,
        pageSize: 100,
      },
      callAGV: {
        itemId: "",
      },
      index: 0,
      rules: {
        planInQnty: [
          {
            require: true,
            pattern: /^\d*.?\d*[0-9]+\d*$|^[0-9]+\d*.d*$/,
            message: "请输入大于0的数字!",
            trigger: "change",
          },
        ],
      },
      field101Options: [{
        "label": "左",
        "value": "X2-BH01-00"
      }, {
        "label": "右",
        "value": "X2-BH02-00"
      }],
      field101: "X2-BH01-00" //补货位置
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$refs.callAgvItemID.focus();
    });
  },
  methods: {
    //料箱放行
    contBack(){
      if (this.formEmptyRegister.contNo == null || this.formEmptyRegister.contNo == "") {
        
        this.$message({
          
              message:'箱号不能为空',
              type:'error',
              center:true,
              showClose:true
          })
        //this.$refs.callAgvItemID.focus();
      }else {
        this.$confirm('確認放行料箱入庫嗎', '提示', {
          confirmButtonText: '確認',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // 用户点击了"确定"
          this.formEmptyRegister.stn = this.$store.state.user.stn
          this.$http['post']('/wms/task/contback', this.formEmptyRegister).then(({ data: res }) => {
            if (res.code !== 0) {
              return this.$message.error(res.msg)
            }
            this.$message({
              message: this.$t('prompt.success'),
              type: 'success',
              duration: 1000,
              onClose: () => {
                this.visible = true
                this.formEmptyRegister.contNo = ''
                //this.$emit('refreshDataList')
              }
            })
          }).catch(() => { })
        }).catch(() => {
          // 用户点击了"取消"
          //console.log("操作被取消");
        });

      }



    },

    //空箱入库登记
    emptyContRegister(){
      if (this.formEmptyRegister.contNo == null || this.formEmptyRegister.contNo == "") {
        
        this.$message({
          
              message:'箱號不能为空',
              type:'error',
              center:true,
              showClose:true
          })
        //this.$refs.callAgvItemID.focus();
      }
      if (this.formEmptyRegister.countType == null || this.formEmptyRegister.countType == "") {
        
        this.$message({
          
              message:'箱類型不能为空',
              type:'error',
              center:true,
              showClose:true
          })
        //this.$refs.callAgvItemID.focus();
      }
      if (this.formEmptyRegister.contVolume == null || this.formEmptyRegister.contVolume == "") {
        
        this.$message({
          
              message:'箱體積不能为空',
              type:'error',
              center:true,
              showClose:true
          })
        //this.$refs.callAgvItemID.focus();
      }else {
        this.formEmptyRegister.stn = this.$store.state.user.stn
        this.$http['post']('/wms/task/request-in', this.formEmptyRegister).then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          }
          this.$message({
            message: this.$t('prompt.success'),
            type: 'success',
            duration: 1000,
            onClose: () => {
              this.visible = true
              //this.formEmptyRegister.contNo = ''
              //this.$emit('refreshDataList')
            }
          })
        }).catch(() => { })
      }

    },
     //A,B不能確定箱類型
    contTypeSelect(){
      if(this.formEmptyRegister.contNo.charAt(0)=='A')
      {
        this.formEmptyRegister.countType = '1'
      }
      else
      {
        this.formEmptyRegister.countType = '3'
      }
    },

  },
};
</script>

<style lang="scss" scoped>
.el-col {
  border-radius: 4px;
}
.el-radio-group{
  padding-left: 20px;
}
</style>

  